//引入ajax
import {Qrcode} from "./request.js"
let span =document.querySelector("span")
let img = document.querySelector("img")
let pp =document.querySelector(".title>p")
async function show(){
    let data = {
        token:sessionStorage.getItem("token"),
        id:sessionStorage.getItem("id")
    }
    let res = await Qrcode(data)
    let y = sessionStorage.getItem("day_time").split("-")[0]
    let m = sessionStorage.getItem("day_time").split("-")[1]
    let d = sessionStorage.getItem("day_time").split("-")[2]
    let t = sessionStorage.getItem("show_name")
    console.log(sessionStorage.getItem("show_name"));
    console.log(sessionStorage.getItem("day_time"));
    pp.innerHTML += `<p>欢迎您在${m}月${d}日${t}参观${y}广州国际花卉艺术展暨中国插花花艺展。</p>`
    span.innerHTML = sessionStorage.getItem("name");
    img.src = res.data.data;
    let btn = document.querySelector(".jilv")
    let btn1 = document.querySelector(".jixu")
    let btn2 = document.querySelector(".home")

btn.addEventListener("click",function(){
    location.href = "./mybook.html"
})
btn1.addEventListener("click",function(){
    location.href = "./book.html"
})
btn2.addEventListener("click",function(){
    location.replace ("./index.html")
})
}
show()

// 保存图片
let btn = document.querySelector(".btn")
btn.addEventListener("click",function(){
    html2canvas(document.documentElement).then(function (canvas) {
        let url = canvas.toDataURL();
        let newImg = document.createElement('img');
        newImg.src = url
        // console.log(url);
        let a = document.createElement('a')
        a.href = url
        a.download = ''
        a.click()
    })
})

